#define _CRT_SECURE_NO_WARNINGS 1


#include <stdio.h>
int ch[10000];


int main()
{
	
	int arr[2];
	int n, m = 0;
	scanf("%d %d", &n, &m);
	int count = 0;
	
	for (int i = 1; i <= m; i++)
	{
		for (int k = 0; k <= 1; k++)
		{
			scanf("%d", &arr[k]);
		}

		for (int h = 0; h <= n; h++)
		{
			if (h >= arr[0] && h <= arr[1])
			{
				ch[h] = 1;
			}
		}
	}
	for (int l = 0; l <= n; l++)
	{
		if (ch[l] == 0)
		{
			count++;
		}
	}
	printf("%d", count);
	return 0;
}